<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="role-form">
				<div class="select-list">
					<ul>
						<li>
							旺旺号：<input type="text" name="wangwangNumber" id="wangwangNumber"/>
						</li>
						<li>
							联系方式：<input type="text" name="customerPhone" id="customerPhone"/>
						</li>
						<li>
							联系状态：<select id="linkStatus" name="linkStatus">
							<option value="">---请选择---</option>
							<option value="0">未沟通</option>
							<option value="1">淘到客户</option>
							<option value="2">下次联系</option>
							<option value="3">不再联系</option>

						</select>
						</li>


					</ul>
					<ul>
						<li class="select-time">
							<label>导入时间： </label>
							<input type="text" class="time-input" id="beginTime" placeholder="导入时间" name="beginTime"/>

						</li>
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="btn-group-sm" id="toolbar" role="group">

<!--			<a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="data:data:import">-->
<!--				<i class="fa fa-upload"></i> 导入-->
<!--			</a>-->
<!--			<a class="btn btn-success" onclick="$.operate.addFull()" shiro:hasPermission="enter:enter:add">-->
<!--				<i class="fa fa-plus"></i> 录入-->
<!--			</a>-->
			<!--<a class="btn btn-primary " onclick="checkAllEnterForm()" shiro:hasPermission="enter:enter:checkAll">-->
				<!--<i class="fa fa-check"></i> 审核-->
			<!--</a>-->
			<a class="btn btn-warning" onclick="exportExcel()" shiro:hasPermission="management:management:export">
				<i class="fa fa-download"></i> 导出
			</a>
		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
	</div>
</div>
<div th:include="include :: footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('management:management:edit')}]];
	// var removeFlag = [[${@permission.hasPermi('enter:enter:remove')}]];
    var prefix = ctx + "management/management";



    $(function() {
        var options = {
            url: prefix + "/list",
            uniqueId: "dataId",
            // exportUrl: prefix + "/export",
            // sortName: "roleSort",
            modalName: "营销数据",
            columns: [
                {
                    field: 'Number',
                    title: '序号',
                    formatter: function (value, row, index) {
                        return index + 1;
                    },
                },
                {
                    field: 'dataId',
                    title: '序号',
                    visible: false
                },
                {
                    field: 'customerName',
                    title: '客户姓名',
                },
                {
                    field: 'wangwangNumber',
                    title: '旺旺号',
                },
				{
					field: 'productName',
					title: '产品名称',
				},
                {
                    field: 'customerPhone',
                    title: '联系方式',
                },
                {
                    field: 'customerAddress',
                    title: '地址',
                },
                {
                    field: 'enterDate',
                    title: '导入时间',
                },
                {
                    field: 'createBy',
                    title: '操作人',
                },
				// {
				// 	visible: editFlag == 'hidden' ? false : true,
				// 	title: '联系状态',
				// 	align: 'center',
				// 	formatter: function (value, row, index) {
				// 		return statusTools(row);
				// 	}
				// },
				{
					field: 'remark',
					title: '备注',
				},
				{
					title: '操作',
					align: 'center',
					formatter: function(value, row, index) {
						var actions = [];
						actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="goAmoyCustomers(\'' + row.dataId + '\')"><i class="fa fa-plus"></i>淘客户</a> ');
						return actions.join('');
					}
				}
			]
        };
        $.table.init(options);
    });


	/**
	 * 导出Exce表格
	 */
	function exportExcel(){

		window.location.href =prefix+'/exportExcel?wangwangNumber='+$("#wangwangNumber").val()+"&customerPhone="+$("#customerPhone").val() +"&beginTime="+$("#beginTime").val()+"&linkStatus="+$("#linkStatus").val();
	}


	/* 用户状态显示 */
	// function statusTools(row) {
	// 	if (row.linkStatus == 0) {
	// 		return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.dataId + '\')"></i> ';
	// 	} else {
	// 		return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.dataId + '\')"></i> ';
	// 	}
	// }

	/* 用户管理-停用 */
	// function disable(dataId) {
	// 	$.modal.confirm("确认要修改状态吗？", function() {
	// 		$.operate.post(prefix + "/changeStatus", { "dataId": dataId, "linkStatus": 0 });
	// 	})
	// }

	/* 用户管理启用 */
	// function enable(dataId) {
	// 	$.modal.confirm("确认要修改状态吗？", function() {
	// 		$.operate.post(prefix + "/changeStatus", { "dataId": dataId, "linkStatus": 1 });
	// 	})
	// }
	
	// 点击跳转到淘客户的页面
	function goAmoyCustomers(dataId) {
		// 点击的同时需要改变状态，将isOPen的状态改为1
		$.ajax({
			url:prefix + "/changeIsOPen?dataId="+dataId,		//请求地址
			type:"get",			//请求方式
			success:function(data){  //回调函数：数据请求成功之后调用
				console.log(data);  				 //这里的data:从服务器发送回来的数据
			}
		})
		//页面层
		// 跳出弹出框
		window.location.href = prefix + "/toAmoyHtml?dataId="+dataId

	}






</script>
</body>>
</form>
</html>